<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<input type="text" name="" id="" value="" v-focus/>
			<span v-color="'red'">程序员</span>
		</div>
		<script src="../vue.js"></script>
		<script type="text/javascript">
			
			Vue.directive('focus', {
				inserted: function(el) {
					el.focus()
				}
			})
			
			Vue.directive('color', {
				bind: function(el,binding) {
					el.style.color=binding.value
				}
			})
			
			
			var vm = new Vue({
				el: "#app",
				data: {
					msg: "请输入"
				},
				methods: {
					// 内部定义私有自定义指令，只能在自己组件中使用；注意directives是要加S
					directives: {
						focus: {
							inserted: function(el) {
								el.focus
							}
						}
					}
				}
			})
		</script>
	</body>
</html>

